# -*-coding:UTF-8 -*-
from __future__ import unicode_literals

from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.

class MyUser(AbstractUser):
    nike_name = models.CharField(max_length=30,verbose_name='昵称')

class Conment(models.Model):
    P_author = models.ForeignKey('MyUser',max_length=30,verbose_name='作者')
    date = models.DateField(auto_now_add=True,verbose_name='日期')
    context = models.TextField(verbose_name='评论内容')
    fu_conment = models.ForeignKey('Conment',default='',blank=True,null=True,related_name='FU',verbose_name='父评论')
    P_context = models.ForeignKey('Context')

    class Meta:
        verbose_name = '评论'

    def __unicode__(self):
        return self.context
class Model(models.Model):
    name = models.CharField(max_length=20,verbose_name='板块')
    class Meta:
        verbose_name = '板块'
    def __unicode__(self):
        return self.name
class Context(models.Model):
    title = models.CharField(max_length=50,verbose_name='标题')
    context = models.TextField(verbose_name='文章内容')
    img = models.ImageField(upload_to='img',verbose_name='图片')
    author = models.ForeignKey('MyUser',verbose_name='作者')
    date = models.DateField(auto_now_add=True,verbose_name='出版日期')
    model_id = models.ForeignKey('Model',verbose_name='板块信息')
    class Meta:
        verbose_name = '文章'
    def __unicode__(self):
        return self.title
class Person(models.Model):
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)

    def my_property(self):
        return self.first_name + ' ' + self.last_name
    my_property.short_description = "Full name of the person"

    full_name = property(my_property)